package com.ming;

public class MingTest {
    public static void main(String[] args) {
        System.out.println("ming test start");
        int [] arrs = {7,4,3,5,2,9,6};
        System.out.println("插入排序");
        for (int i = 1; i < arrs.length; i++) {
            int tmp = arrs[i];
            int j = i-1;
            for (; j >= 0 ; j--) {
                if (arrs[j]>tmp) {
                    arrs[j+1] = arrs[j];
                } else {
                    break;
                }
            }
            arrs[j+1] = tmp;
        }
        for (int i = 0; i < arrs.length; i++) {
            System.out.println(arrs[i]);
        }


        /*for (int i = 0; i < arrs.length; i++) {
//            System.out.println(arrs[i]);
            for (int j = 0; j < arrs.length - 1 - i; j++) {
                if (arrs[j]>arrs[j+1]) {
                    int tmp = arrs[j];
                    arrs[j] = arrs[j+1];
                    arrs[j+1] = tmp;
                }
            }
        }
        System.out.println("冒泡排序：");
        for (int i = 0; i < arrs.length; i++) {
            System.out.println(arrs[i]);
        }*/


//        for (int i = 0; i < arrs.length; i++) {
//            for (int j = 0; j < arrs.length-i-1; j++) {
//                if (arrs[j]>arrs[j+1]) {
//                    int tmp = arrs[j];
//                    arrs[j] = arrs[j+1];
//                    arrs[j+1] = tmp;
//                }
//            }
//        for (int i = 1; i < arrs.length; i++) {
//            int tmp = arrs[i];
//            int j = i-1;
//            for (; j >=0 ; j--) {
//                if (arrs[j]>tmp) {
//                    arrs[j+1] = arrs[j];
//                } else {
//                    break;
//                }
//            }
//            arrs[j+1] = tmp;
//        }
//        for (int i = 1; i < arrs.length; i++) {
//            int tmp = arrs[i];
//            int j = i-1;
//            for (; j >=0 ; j--) {
//                if (arrs[j]>tmp) {
//                    arrs[j+1] = arrs[j];
//                } else {
//                    break;
//                }
//            }
//            arrs[j+1] = tmp;
//        }

        /*for (int i = 0; i < arrs.length; i++) {
            for (int j = 0; j < arrs.length - i - 1; j++) {
                if (arrs[j]>arrs[j+1]) {
                    int tmp = arrs[j+1];
                    arrs[j+1] = arrs[j];
                    arrs[j] = tmp;
                }
            }
        }
        for (int i = 0; i < arrs.length; i++) {
            System.out.println(arrs[i]);
        }*/
    }
}
